//package pl.edu.pw.perg.compinfodb.ui;
//
//import java.awt.BorderLayout;
//import java.awt.Color;
//import java.awt.Component;
//import java.awt.Dimension;
//import java.awt.FlowLayout;
//import java.awt.event.MouseAdapter;
//import java.awt.event.MouseEvent;
//import java.util.ArrayList;
//import java.util.Collection;
//import java.util.Enumeration;
//import java.util.Iterator;
//import java.util.List;
//
//import javax.swing.BorderFactory;
//import javax.swing.JComboBox;
//import javax.swing.JComponent;
//import javax.swing.JLabel;
//import javax.swing.JPanel;
//import javax.swing.JPopupMenu;
//import javax.swing.JScrollPane;
//import javax.swing.JTable;
//import javax.swing.JTree;
//import javax.swing.event.ListSelectionEvent;
//import javax.swing.event.ListSelectionListener;
//import javax.swing.event.TreeSelectionEvent;
//import javax.swing.event.TreeSelectionListener;
//import javax.swing.table.DefaultTableCellRenderer;
//import javax.swing.table.TableCellRenderer;
//import javax.swing.table.TableModel;
//import javax.swing.tree.DefaultMutableTreeNode;
//import javax.swing.tree.DefaultTreeCellRenderer;
//import javax.swing.tree.DefaultTreeModel;
//import javax.swing.tree.TreeCellRenderer;
//import javax.swing.tree.TreeNode;
//
//import org.springframework.context.ApplicationEvent;
//import org.springframework.context.ApplicationListener;
//import org.springframework.richclient.application.PageComponentContext;
//import org.springframework.richclient.application.support.AbstractView;
//import org.springframework.richclient.command.ActionCommand;
//import org.springframework.richclient.command.CommandGroup;
//import org.springframework.richclient.command.support.AbstractActionCommandExecutor;
//import org.springframework.richclient.command.support.GlobalCommandIds;
//import org.springframework.richclient.dialog.ApplicationDialog;
//import org.springframework.richclient.dialog.CloseAction;
//import org.springframework.richclient.dialog.ConfirmationDialog;
//import org.springframework.richclient.list.ComboBoxListModel;
//import org.springframework.richclient.progress.TreeStatusBarUpdater;
//import org.springframework.richclient.tree.FocusableTreeCellRenderer;
//import org.springframework.richclient.util.PopupMenuMouseListener;
//
//import pl.edu.pw.perg.compinfodb.entities.IVirtualElement;
//import pl.edu.pw.perg.compinfodb.entities.VirtualElement;
//import pl.edu.pw.perg.compinfodb.manager.IElementTypeManager;
//import pl.edu.pw.perg.compinfodb.manager.IFieldManager;
//import pl.edu.pw.perg.compinfodb.manager.IPhysicalElementManager;
//import pl.edu.pw.perg.compinfodb.manager.IVirtualElementManager;
//
//@SuppressWarnings("serial")
//public class EquipmentManagerView extends AbstractView implements
//		ApplicationListener, IEquipmentManagerView, ListSelectionListener {
//
//	private IVirtualElementManager virtualElementManager;
//	private IPhysicalElementManager physicalElementManager;
////	private IElementCategoryManager categoryManager;
//	private IElementTypeManager typeManager;
//	private IFieldManager fieldManager;
//
//	private JTree elementTree;
//	private DefaultTreeModel elementTreeModel;
////	private JTree chosenElementTree;
//	private JTable table;
//	private DefaultTreeModel chosenElementTreeModel;
//	private ChoseElementExecutor choseExecutor = new ChoseElementExecutor();
//	private DeleteExecutor deleteExecutor = new DeleteExecutor();
//	private final VisibleTreeNode viewRootNode = new VisibleTreeNode("Slave");
//	private TableModel equipmentTableModel;
////	private FilterableComboBoxListModel<ElementCategory> categoryComboModel;
//	private ComboBoxListModel typeComboModel;
////	private JComboBox categoryCombo;
//	private JComboBox typeCombo;
//	private NewElementAction newEltCommand = new NewElementAction();
//	private SwitchToSearchModeExecutor searchModeExecutor = new SwitchToSearchModeExecutor();
//	private SearchExecutor searchExecutor = new SearchExecutor();
////	private ColorRenderer cellRenderer = new ColorRenderer();
//	private SaveExecutor saveExecutor = new SaveExecutor();
////	private ImportCommand importCommand;
//
//
//	//
//	//
//	@Override
//	protected JComponent createControl() {
//		JPanel view = new JPanel(new BorderLayout());
//		createEquipmentManagerTree();
////		createSlaveTree();
////		createCategoryCombo();
////		createTypeCombo();
////		createEquipmentTable();
//		JScrollPane sp1 = new JScrollPane(elementTree);
//		sp1.setBorder(BorderFactory.createTitledBorder("Element Tree"));
//
//		JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEADING));
//		JLabel l1 = new JLabel("Element Category:");
//		JLabel l2 = new JLabel(" Element Type:");
//		p1.add(l1);
////		p1.add(categoryCombo);
//		p1.add(l2);
////		p1.add(typeCombo);
//		JPanel p2 = new JPanel(new BorderLayout());
//		p2.add(p1, BorderLayout.PAGE_START);
//		JScrollPane sp4 = new JScrollPane(table);
//		sp4
//				.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
//
//		p2.add(sp4, BorderLayout.CENTER);
//
//		JScrollPane sp3 = new JScrollPane(p2);
//		sp3.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
//		sp3.setBorder(BorderFactory.createTitledBorder("Element Details"));
//		sp1.setPreferredSize(new Dimension(140, 100));
////		JScrollPane sp2 = new JScrollPane(chosenElementTree);
////		sp2.setPreferredSize(new Dimension(140, 100));
//
////		sp2.setBorder(BorderFactory.createTitledBorder("Selected Elements"));
////		JSplitPane spl1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp1, sp2);
//
////		JSplitPane spl2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, spl1, sp3);
////		view.add(spl2, BorderLayout.CENTER);
//		return view;
//
//	}
//
//	protected void registerLocalCommandExecutors(PageComponentContext context) {
//		context.register("choseCommand", choseExecutor);
//		context.register("saveCommand", saveExecutor);
//		context.register("searchCommand", searchExecutor);
////		context.register("importCommand", importCommand);
//		context.register(GlobalCommandIds.DELETE, deleteExecutor);
//	}
//
//	private VisibleTreeNode createTree(IVirtualElement elt) {
//		VisibleTreeNode rootNode = new VisibleTreeNode(elt);
//		Collection<VirtualElement> children = elt.getChildren();
//		for (Iterator<VirtualElement> i = children.iterator(); i.hasNext();) {
//			IVirtualElement child = (IVirtualElement) i.next();
//			rootNode.add(createTree(child));
//		}
//		return rootNode;
//
//	}
//
////	private void createCategoryCombo() {
////		categoryComboModel = new FilterableComboBoxListModel<ElementCategory>(
////				categoryManager, "categoryName");
////		categoryCombo = new JComboBox(categoryComboModel);
////		// categoryCombo.addActionListener(equipmentTableModel);
////	}
////
////	private void createTypeCombo() {
////		typeComboModel = new ComboBoxListModel(
////				typeManager, "elementCategory");
////		typeCombo = new JComboBox(typeComboModel);
////		typeCombo.addActionListener(equipmentTableModel);
//////		categoryCombo.addActionListener(typeComboModel);
////
////	}
//
//	@SuppressWarnings("serial")
////	private void createEquipmentTable() {
////		equipmentTableModel = new FilterableTableModel(physicalElementManager);
////		// equipmentTableModel.setMasterSlaveMappings(categoryCombo,
////		// slaveFieldName)
////		// Object type = typeComboModel.getSelectedItem();
////		// if(type != null){
////		// List<Field> fields = ((ElementType)type).getFields();
////		// equipmentTableModel.setColumns(fields);
////		// }
////		equipmentTableModel.setColumnModelSource(typeCombo);
////		table = new JTable(equipmentTableModel){
////			@Override
////			public void tableChanged(TableModelEvent e) {
////				super.tableChanged(e);
////				for (int i = 0; i < getColumnCount(); i++) {
////					getColumnModel().getColumn(i).setCellRenderer(new ColorRenderer());
////				}
////			}
////		};
////		table.getSelectionModel().addListSelectionListener(this);
////
////		typeCombo.addActionListener(equipmentTableModel);
////		chosenElementTreeModel.addTreeModelListener(equipmentTableModel);
////
////	}
//
//	private void createEquipmentManagerTree() {
//		VisibleTreeNode rootNode = new VisibleTreeNode("CMS");
//		List<VirtualElement> elements = virtualElementManager.findRoots();
//		for (Iterator<VirtualElement> i = elements.iterator(); i.hasNext();) {
//			IVirtualElement elt = (VirtualElement) i.next();
//			VisibleTreeNode eltNode = createTree(elt);
//			rootNode.add(eltNode);
//		}
//		//
//		// Element el = elements.iterator().next();
//		// String[] a = new String[1];
//		//
//		// List<Field> fields =
//		// fieldManager.findFields(FieldManager.ELEMENT_TYPE,
//		// el.getElementType());
//		// a[0] = fields.get(0).getFieldName();
//		// String[][] aa = {{"aaaaaa"}};
//		// table = new JTable(aa,a );
//		//
//		this.elementTreeModel = new DefaultTreeModel(rootNode);
//		this.elementTree = new JTree(elementTreeModel);
//		elementTree.setShowsRootHandles(true);
//		elementTree.addTreeSelectionListener(new TreeStatusBarUpdater(
//				getStatusBar()) {
//			public String getSelectedObjectName() {
//				IVirtualElement selectedElt = getSelectedElement(elementTree);
//				if (selectedElt != null)
//					return selectedElt.toString();
//
//				return "CMS";
//			}
//		});
//		elementTree.addTreeSelectionListener(new TreeSelectionListener() {
//			public void valueChanged(TreeSelectionEvent e) {
//				updateCommands();
//				if (getSelectedElementNode(elementTree) != null)
////					chosenElementTree.clearSelection()
//				  ;
//			}
//		});
//		elementTree.addMouseListener(new PopupMenuMouseListener() {
//			protected boolean onAboutToShow(MouseEvent e) {
//				return !isRootOrNothingSelected();
//			}
//
//			//
//			protected JPopupMenu getPopupMenu() {
//				return createElementPopupContextMenu();
//			}
//		});
//		elementTree.addMouseListener(new MouseAdapter() {
//			public void mouseClicked(MouseEvent e) {
//				if (e.getClickCount() == 2
//						&& e.getButton() == MouseEvent.BUTTON1
//						&& choseExecutor.isEnabled()) {
//					choseExecutor.execute();
//				}
//			}
//		});
//
//		elementTree.setCellRenderer(getTreeCellRenderer());
//		elementTree.setRootVisible(true);
//	}
//
////	private void createSlaveTree() {
////
////		this.chosenElementTreeModel = new DefaultTreeModel(viewRootNode);
////		this.chosenElementTree = new JTree(chosenElementTreeModel);
////		chosenElementTree.setShowsRootHandles(true);
////		chosenElementTree.addTreeSelectionListener(new TreeStatusBarUpdater(
////				getStatusBar()) {
////			public String getSelectedObjectName() {
////				IVirtualElement selectedElt = getSelectedElement(elementTree);
////				if (selectedElt != null)
////					return selectedElt.toString();
////
////				return "CMS";
////			}
////		});
////		chosenElementTree.addTreeSelectionListener(new TreeSelectionListener() {
////			public void valueChanged(TreeSelectionEvent e) {
////				if (getSelectedElementNode(chosenElementTree) != null)
////					elementTree.clearSelection();
////				updateCommands();
////			}
////		});
////		chosenElementTree.addMouseListener(new PopupMenuMouseListener() {
////			protected boolean onAboutToShow(MouseEvent e) {
////				return !isRootOrNothingSelected();
////			}
////
////			// //
////			protected JPopupMenu getPopupMenu() {
////				return createElementPopupContextMenu();
////			}
////		});
////		// elementTree.addMouseListener(new MouseAdapter() {
////		// public void mouseClicked(MouseEvent e) {
////		// if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 &&
////		// choseExecutor.isEnabled()) {
////		// choseExecutor.execute();
////		// }
////		// }
////		// });
////		chosenElementTree.addFocusListener(new FocusListener() {
////
////			public void focusGained(FocusEvent e) {
////				// choseExecutor.setEnabled(true);
////				// updateCommands();
////			}
////
////			public void focusLost(FocusEvent e) {
////				// choseExecutor.setEnabled(false);
////			}
////
////		});
////		chosenElementTree.setCellRenderer(getTreeCellRenderer());
////		chosenElementTree.setRootVisible(false);
////	}
//
//	private DefaultTreeCellRenderer treeCellRenderer = new FocusableTreeCellRenderer() {
//
//		public Component getTreeCellRendererComponent(JTree tree, Object value,
//				boolean sel, boolean expanded, boolean leaf, int row,
//				boolean hasFocus) {
//			super.getTreeCellRendererComponent(tree, value, sel, expanded,
//					leaf, row, hasFocus);
//			DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
//			if (node.isRoot()) {
//				this.setIcon(getIconSource().getIcon("cms.bullet"));
//			} else {
//				Object userObject = node.getUserObject();
//				if (userObject instanceof IVirtualElement) {
//				  IVirtualElement o = (IVirtualElement) userObject;
//					this.setText(o.toString());
//					this.setIcon(getIconSource().getIcon("owner.bullet"));
//				}
//
//			}
//			return this;
//		}
//	};
//
//	/*
//	 * (non-Javadoc)
//	 *
//	 * @see pl.edu.pw.perg.compinfodb.ui.IEquipmentManagerView#getTreeCellRenderer()
//	 */
//	public TreeCellRenderer getTreeCellRenderer() {
//		return treeCellRenderer;
//	}
//
//	/*
//	 * (non-Javadoc)
//	 *
//	 * @see pl.edu.pw.perg.compinfodb.ui.IEquipmentManagerView#getElementManager()
//	 */
//	public IPhysicalElementManager getPhysicalElementManager() {
//		return physicalElementManager;
//	}
//
//	public IVirtualElementManager getVirtualElementManager() {
//		return virtualElementManager;
//	}
//
//	/*
//	 * (non-Javadoc)
//	 *
//	 * @see pl.edu.pw.perg.compinfodb.ui.IEquipmentManagerView#setElementManager(pl.edu.pw.perg.compinfodb.manager.IElementManager)
//	 */
//	public void setPhysicalElementManager(IPhysicalElementManager elementManager) {
//		this.physicalElementManager = elementManager;
//	}
//
//	public void setVirtualElementManager(IVirtualElementManager elementManager) {
//		this.virtualElementManager = elementManager;
//	}
//
//	private static DefaultMutableTreeNode getSelectedElementNode(JTree tree) {
//		DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree
//				.getLastSelectedPathComponent();
//		if (node == null || !(node.getUserObject() instanceof IVirtualElement))
//			return null;
//		return node;
//	}
//
//	private static IVirtualElement getSelectedElement(JTree tree) {
//		DefaultMutableTreeNode node = getSelectedElementNode(tree);
//		if (node != null)
//			return (IVirtualElement) node.getUserObject();
//
//		return null;
//	}
//
//	/*
//	 * (non-Javadoc)
//	 *
//	 * @see pl.edu.pw.perg.compinfodb.ui.IEquipmentManagerView#onApplicationEvent(org.springframework.context.ApplicationEvent)
//	 */
//	public void onApplicationEvent(ApplicationEvent arg0) {
//
//	}
//
//	private void updateCommands() {
//		choseExecutor.setEnabled(true);
//		deleteExecutor.setEnabled(true);
//		searchExecutor.setEnabled(true);
//		searchModeExecutor.setEnabled(true);
//		saveExecutor.setEnabled(false);
////		importCommand.setEnabled(true);
//
//		newEltCommand.setEnabled(getSelectedElement(elementTree) != null);
//		VisibleTreeNode selected = (VisibleTreeNode) getSelectedElementNode(elementTree);
//		// jesli nie zaznaczono zadnego elementu lub jest on juz wybrany
//		if (selected == null || selected.isVisible())
//			choseExecutor.setEnabled(false);
//
////		if (getSelectedElementNode(chosenElementTree) == null)
////			deleteExecutor.setEnabled(false);
//		if (!searchModeExecutor.isEnabled())
//			searchExecutor.setEnabled(false);
////		if(equipmentTableModel.isNewSelected(table.getSelectedRows()))
////			saveExecutor.setEnabled(true);
//
//	}
//
//	private boolean isRootOrNothingSelected() {
//		return elementTree.getSelectionCount() == 0
//				|| (elementTree.getSelectionCount() == 1 && elementTree
//						.isRowSelected(0));
//	}
//
//	// TODO: implementacja - tworzenie nowego elementu - wywolywana na
//	// konkretnym
//	// elemencie, ktory staje sie rodzicem tworzonego. Stworzyc dialog, w ktorym
//	// bedzie wybor typu, przycisk wywolujacy dialog nowego typu, lista pol
//	// i atrybuty do wypelnienia.
//
//	private class NewElementAction extends ActionCommand {
//
//		private ApplicationDialog dialog;
//
////		private ElementForm eltForm;
//
////		private ElementDialogPage dialogPage;
//
//		/**
//		 * Constructor with fixed command id which will be used to configure
//		 * it's label/icon etc...
//		 */
//		public NewElementAction() {
//			super("newElementCommand");
//		}
//
//		/**
//		 * Create the dialog with {@link CloseAction#HIDE}. This will keep the
//		 * dialog hidden in order to reuse the component. This avoids the
//		 * time-consuming building of the dialog gui each time.
//		 */
//		private void createDialog() {
////			TODO:
////
////			IVirtualElement selectedElement = getSelectedElement(elementTree);
////			VirtualElement newElement = new VirtualElement(selectedElement.getElementType(),
////					selectedElement.getParent());
////			eltForm = new ElementForm(new ElementFormModel(newElement),
////					"elementProperties");
////			dialogPage = new ElementDialogPage(eltForm, "elementProperties");
////
////			dialog = new TitledPageApplicationDialog(dialogPage,
////					getWindowControl(), CloseAction.DISPOSE) {
////				protected void onAboutToShow() {
////					eltForm.requestFocusInWindow();
////					setEnabled(dialogPage.isPageComplete());
////				}
////
////				protected boolean onFinish() {
////					// eltForm.commit();
////					Element elt = (Element) eltForm.getFormObject();
////					elt.setPersistent(false);
////					elt.setEditable(true);
////					getSelectedElement(elementTree).addChild(
////							elt);
////					// clinic.storePet(newPet);
////					DefaultMutableTreeNode parentNode = getSelectedElementNode(elementTree);
////					parentNode.add(new VisibleTreeNode(elt));
////					elementTreeModel.nodeStructureChanged(parentNode);
////					equipmentTableModel.addToModel(elt);
////					return true;
////				}
////			};
//		}
//
//		protected void doExecuteCommand() {
////			if (dialog == null)
//				createDialog();
//
//			dialog.showDialog();
//		}
//	}
//
//	/**
//	 * Finds a corresponding (with the same object as value) node on the second
//	 * tree, passed by
//	 *
//	 * @param root
//	 *            argumnet.
//	 */
//	@SuppressWarnings("unchecked")
//	private static DefaultMutableTreeNode findACorrespondingNode(
//			DefaultMutableTreeNode root, DefaultMutableTreeNode aNode) {
//		if (root.getUserObject().equals(aNode.getUserObject()))
//			return root;
//		for (Enumeration e = root.children(); e.hasMoreElements();) {
//			DefaultMutableTreeNode node = findACorrespondingNode(
//					(DefaultMutableTreeNode) e.nextElement(), aNode);
//			if (node != null)
//				return node;
//
//		}
//		return null;
//	}
//
//	/**
//	 * Returns a copy of a branch, starting on
//	 *
//	 * @param copiedTreeRoot.
//	 */
//	private static DefaultMutableTreeNode copySubtree(
//			DefaultMutableTreeNode copiedTreeRoot) {
//		DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(
//				copiedTreeRoot.getUserObject());
//		for (Enumeration e = copiedTreeRoot.children(); e.hasMoreElements();) {
//
//			DefaultMutableTreeNode node = copySubtree((DefaultMutableTreeNode) e
//					.nextElement());
//			newNode.add(node);
//		}
//		return newNode;
//
//	}
//
//	/**
//	 * Returns a copy of a branch, starting on
//	 *
//	 * @param copiedTreeRoot,
//	 *            but including only visible children.
//	 */
//	@SuppressWarnings("unchecked")
//	private static VisibleTreeNode copyVisibleSubtree(
//			VisibleTreeNode copiedTreeRoot) {
//		if (!copiedTreeRoot.isVisible())
//			return null;
//		VisibleTreeNode newNode = new VisibleTreeNode(copiedTreeRoot
//				.getUserObject());
//		for (Enumeration e = copiedTreeRoot.children(); e.hasMoreElements();) {
//
//			VisibleTreeNode node = copyVisibleSubtree((VisibleTreeNode) e
//					.nextElement());
//			if (node == null)
//				continue;
//			newNode.add(node);
//		}
//		return newNode;
//
//	}
//
//	private static VisibleTreeNode generateTreeModelView(DefaultTreeModel tm,
//			VisibleTreeNode viewRoot) {
//		VisibleTreeNode root = new VisibleTreeNode(viewRoot);
//		List<VisibleTreeNode> rootNodes = getViewRoot((VisibleTreeNode) tm
//				.getRoot());
//		// DefaultTreeModel treeModelView = new DefaultTreeModel(root);
//		for (VisibleTreeNode node : rootNodes) {
//			root.add(copyVisibleSubtree(node));
//		}
//		return root;
//	}
//
//	/**
//	 * Finds visible nodes on the highest level in each branch.
//	 *
//	 * @param root
//	 * @return
//	 */
//	@SuppressWarnings("unchecked")
//	private static List<VisibleTreeNode> getViewRoot(VisibleTreeNode root) {
//		List<VisibleTreeNode> visibleRoots = new ArrayList<VisibleTreeNode>();
//		if (root.isVisible())
//			visibleRoots.add(root);
//		for (Enumeration e = root.children(); e.hasMoreElements();) {
//			VisibleTreeNode node = (VisibleTreeNode) e.nextElement();
//			if (node.isVisible())
//				visibleRoots.add(node);
//			else
//				visibleRoots.addAll(getViewRoot(node));
//		}
//		return visibleRoots;
//	}
//
//	private class SwitchToSearchModeExecutor extends
//			AbstractActionCommandExecutor {
//
//		public void execute() {
////			equipmentTableModel.swichToSearchMode();
//		}
//
//	}
//
//	private class SearchExecutor extends AbstractActionCommandExecutor {
//
//		public void execute() {
////			equipmentTableModel.search();
//		}
//
//	}
//
//	private class ChoseElementExecutor extends AbstractActionCommandExecutor {
//		public void execute() {
//
//			VisibleTreeNode selected = (VisibleTreeNode) getSelectedElementNode(elementTree);
//			selected.setVisible(true);
//			chosenElementTreeModel.setRoot(generateTreeModelView(
//					elementTreeModel, viewRootNode));
//			// chosenElementTree.setModel(chosenElementTreeModel);
//			chosenElementTreeModel
//					.nodeStructureChanged((TreeNode) chosenElementTreeModel
//							.getRoot());
//			updateCommands();
//
//		}
//	}
//
//	private JPopupMenu createElementPopupContextMenu() {
//		// delete, chose, edit
//		CommandGroup group = getWindowCommandManager().createCommandGroup(
//				"elementViewTableCommandGroup",
//				new Object[] { "choseCommand", "separator", "deleteCommand",
//						newEltCommand });
//		return group.createPopupMenu();
//	}
//
//	private class DeleteExecutor extends AbstractActionCommandExecutor {
//		@SuppressWarnings("unchecked")
//		public void execute() {
//			// int elementCount = 0;
//			final List nodesToDelete = new ArrayList();
////			TreePath[] paths = chosenElementTree.getSelectionPaths();
////			for (int i = 0; i < paths.length; i++) {
////				DefaultMutableTreeNode node = (DefaultMutableTreeNode) paths[i]
////						.getLastPathComponent();
////				if (node.isRoot()) {
////					continue;
////				}
////				nodesToDelete.add(node);
////			}
//
//			ConfirmationDialog dialog = new ConfirmationDialog() {
//				protected void onConfirm() {
//					for (Iterator i = nodesToDelete.iterator(); i.hasNext();) {
//						DefaultMutableTreeNode node = (DefaultMutableTreeNode) i
//								.next();
//
//						chosenElementTreeModel.removeNodeFromParent(node);
//						chosenElementTreeModel
//								.nodeStructureChanged((TreeNode) chosenElementTreeModel
//										.getRoot());
//						VisibleTreeNode corresponding = (VisibleTreeNode) findACorrespondingNode(
//								(VisibleTreeNode) elementTreeModel.getRoot(),
//								node);
//						corresponding.setVisible(false);
//						updateCommands();
//					}
//				}
//			};
//			// dialog.setCloseAction(CloseAction.DISPOSE);
//
////			if (paths.length > 0) {
////				dialog.setTitle(getMessage("confirmDeleteElement.title"));
////				dialog
////						.setConfirmationMessage(getMessage("confirmDeleteElement.label"));
////			}
//			dialog.showDialog();
//		}
//	}
//
//	private class SaveExecutor extends AbstractActionCommandExecutor {
//
//		@SuppressWarnings("unchecked")
//		public void execute() {
//			int count = table.getSelectedRowCount();
//			if(count == 0)
//				return;
////			FilterableTableModel<ITableData> model = (FilterableTableModel<ITableData>)
//				table.getModel();
////			model.saveRows(table.getSelectedRows());
//		}
//	}
//
//	@SuppressWarnings("serial")
//	private class ColorRenderer extends DefaultTableCellRenderer implements TableCellRenderer {
//
//		public ColorRenderer() {
////			setOpaque(true); // MUST do this for background to show up.
//		}
//
//		@SuppressWarnings("unchecked")
//		public Component getTableCellRendererComponent(JTable table,
//				Object obj, boolean isSelected, boolean hasFocus, int row,
//				int column) {
//			Component cell = super.getTableCellRendererComponent(
//                    table, obj, isSelected, hasFocus, row, column);
//
//			Color filterColor = new Color(170, 202, 215);
//			Color newColor = new Color(215, 205, 170);
////		Color filterColor = new Color(0x5C, 0xC5, 0xC4);
////			Color newColor = new Color(0x5E, 0xC5, 0x5C);
//			if(row == 0 && !isSelected){
//				cell.setBackground(filterColor);
//			}
////			else if(!((FilterableTableModel<ITableData>) table.getModel()).
////					isRowPersistent(row))
////				cell.setBackground(newColor);
//			else if(!isSelected)
//				cell.setBackground(new Color(255,255,255));
//
//			return cell;
//		}
//	}
//
//	private static class VisibleTreeNode extends DefaultMutableTreeNode {
//
//		private static final long serialVersionUID = -8241653470048786736L;
//
//		private boolean visible;
//
//		public boolean isVisible() {
//			return visible;
//		}
//
//		public void setVisible(boolean isVisible) {
//			this.visible = isVisible;
//			if (children != null)
//				for (Object node : children) {
//					((VisibleTreeNode) node).setVisible(isVisible);
//				}
//		}
//
//		public VisibleTreeNode(Object obj) {
//			super(obj);
//			visible = false;
//		}
//
//		public VisibleTreeNode(VisibleTreeNode node) {
//			this(node.userObject);
//			setVisible(node.visible);
//		}
//
//	}
//
//	public IFieldManager getFieldManager() {
//		return fieldManager;
//	}
//
//	public void setFieldManager(IFieldManager fieldManager) {
//		this.fieldManager = fieldManager;
//	}
//
////	public IElementCategoryManager getCategoryManager() {
////		return categoryManager;
////	}
////
////	public void setCategoryManager(IElementCategoryManager categoryManager) {
////		this.categoryManager = categoryManager;
////	}
//
//	public IElementTypeManager getTypeManager() {
//		return typeManager;
//	}
//
//	public void setTypeManager(IElementTypeManager typeManager) {
//		this.typeManager = typeManager;
//	}
//
//	public void valueChanged(ListSelectionEvent e) {
//		updateCommands();
//
//	}
//
////	public void setImportCommand(ImportCommand importCommand) {
////		this.importCommand = importCommand;
////	}
//
//}
